package real

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"net/http/httputil"
)

type RetrieverForBaidu struct {
	Name  string
	Title string
}

func (retriever RetrieverForBaidu) Get(url string) string {
	get, err := http.Get(url)
	defer func(Body io.ReadCloser) {
		err := Body.Close()
		if err != nil {
			log.Fatal("关闭 body 时出错")
		}
	}(get.Body)

	if err != nil {
		log.Fatal("调用{}出错", url)
	}

	response, err := httputil.DumpResponse(get, true)
	if err != nil {
		log.Fatal("body 解析错误")
	}
	return string(response)
}

func (retriever RetrieverForBaidu) String() string {
	return fmt.Sprintf("RetrieverForBaidu name is :{%s}", retriever.Name)
}
